package com.ssy.lingxi.member.merchant.model.bo;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;

/**
 * 省市区域BO
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-21
 */
public class AreaBO implements Serializable {
    private static final long serialVersionUID = 1782998434463673245L;

    public AreaBO() {
    }

    public AreaBO(String provinceCode, String province, String cityCode, String city) {
        this.provinceCode = provinceCode;
        this.province = province;
        this.cityCode = cityCode;
        this.city = city;
    }

    /**
     * 省编码
     */
    @JsonProperty("pc")
    private String provinceCode;

    /**
     * 省份
     */
    @JsonProperty("p")
    private String province;

    /**
     * 城市编码
     */
    @JsonProperty("cc")
    private String cityCode;

    /**
     * 城市
     */
    @JsonProperty("c")
    private String city;

    public String getProvinceCode() {
        return provinceCode;
    }

    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Override
    public boolean equals(Object obj) {
        //地址相等
        if(this == obj){
            return true;
        }

        if(obj == null){
            return false;
        }

        if(obj instanceof AreaBO){
            AreaBO other = (AreaBO) obj;

            if(this.getProvince() == null && other.getProvince() != null) {
                return false;
            }

            if(this.getProvince() != null && other.getProvince() == null) {
                return false;
            }

            if(this.getProvinceCode() == null && other.getProvinceCode() != null) {
                return false;
            }

            if(this.getProvinceCode() != null && other.getProvinceCode() == null) {
                return false;
            }

            if(this.getCityCode() == null && other.getCityCode() != null) {
                return false;
            }

            if(this.getCityCode() != null && other.getCityCode() == null) {
                return false;
            }

            if(this.getCity() == null && other.getCity() != null) {
                return false;
            }

            if(this.getCity() != null && other.getCity() == null) {
                return false;
            }

            return this.getProvince().equals(other.getProvince()) && this.getProvinceCode().equals(other.getProvinceCode()) && this.getCity().equals(other.getCity()) && this.getCityCode().equals(other.getCityCode());
        }

        return false;
    }
}
